var t = require("../../api.js"), a = getApp(), e = 0, i = 0, o = !0, r = 1, s = "", n = !1;
var h = require("../../api.js"), j = getApp();
Page({

    data: {
        sub_btn: true,
        xyshow:true,
        check:false,
        imageList: [],
        shoose:false,
        haibao:1
    },

    onLoad: function (options) {
        var that = this;
        getApp().pageOnLoad(this, options);
       a.request({
           url:h.default.ghs_type,
           method:'POST',
           data:{

           },
           success:function (e) {
               if(e.code==0){
                   that.setData({
                       code:0,
                       setting:e.setting
                   })
               }
               if(e.code==1){
                   console.log(e.info);
                   that.setData({
                       code:1,
                       supplier_data:e.info
                   })
               }
           }
       })
    },
  image_show: function () {
    this.setData({
      haibao: 0
    })
  },
    tiaozhuan:function(){
        wx.redirectTo({
            url:this.data.url,
        })
    },

    onReady: function() {

    },

    onShow: function() {

    },

    onHide: function() {

    },
    hyxzboxshow: function (e) {
        this.setData({
            xyshow: false
        })
    },
    hyxzboxhide: function (e) {
        this.setData({
            xyshow: true,
            check:true,
            sub_btn: false
        })
    },
    read:function() {
        this.setData({
            code:0
        })
    },
    chooseImage: function () {
        var that = this
        wx.chooseImage({
            sourceType: ['album', 'camera'],
            count: 1,
            success: function (res) {
                that.setData({
                    imageList: res.tempFilePaths,
                    shoose:true
                })
            }
        })
    },
    formSubmit:function (e) {
        var that = this;
        let {supplier_name,mobile,name,goods,remarks} = e.detail.value;
        wx.showLoading({
            title: '提交中',
        });
        a.request({
            url: h.default.ghs_save,
            method:'POST',
            data:{
                supplier_name:supplier_name,
                goods:goods,
                remarks:remarks,
                mobile:mobile,
                name:name,
            },
            success:function (e) {
                wx.hideLoading();
                if(e.code>0){
                    wx.showModal({
                        title:'提示',
                        content: e.info,
                        showCancel:false,
                    })
                }
                if(e.code==0){
                    wx.showModal({
                        title:'提示',
                        content: e.info,
                        showCancel:false,
                        success:function (e) {
                            wx.navigateTo({    //保留当前页面，跳转到应用内的某个页面（最多打开5个页面，之后按钮就没有响应的）
                                url:"/pages/index/index"
                            })
                        }
                    })
                }

            },
            fail:function () {
                wx.showModal({
                    title:'提示',
                    content: '提交失败',
                    showCancel:false,
                })
            }
        })



    }
})